home *** CD-ROM | disk | FTP | other *** search
/ World of Amiga / World of Amiga.iso / archive / assembly / b-block1.lha / B_Block_Load.s < prev    next >
Text File  |  1980-01-01  |  5KB  |  117 lines

  1. ; *** BBLoad written by Gerson Kurz ***
  2. ;
  3. ; Size : 644 Bytes !!
  4. ;
  5. ; Das ist das Gegenstueck zu BBSave. Hier wird ein File in den Bootblock
  6. ; Geschrieben....
  7. ; -----------------------------------------------------------------
  8. ; Diesmal suchen wir uns auch zuerst einen Task
  9. ; -----------------------------------------------------------------
  10. o:    cmp.b    #1,d0        ; Keine Parameter ?
  11.     bls.l    nofile        ; Ja, Error !
  12.     movem.l    d0-d3/a0-a4,-(sp); Register sichern
  13.     move.l    4,a6        ; Execbase als Basisadr.
  14.     suba.l    a1,a1        ; eigener Task
  15.     jsr    -294(a6)    ; ExecCall FINDTASK
  16.     move.l    d0,readreply+$10; Zeiger auf eigenen Task
  17.     lea    readreply,a1    ; Task herholen
  18.     jsr    -354(a6)    ; ExecCall ADDPORT
  19.     movem.l    (sp)+,d0-d3/a0-a4; Register zurueckholen
  20. ; -----------------------------------------------------------------
  21. ; Aber dann holen wir uns den CLI Eingabestring her...
  22. ; -----------------------------------------------------------------
  23.     lea    $60000,a1    ; String fuer Filename nach a1
  24. search:    move.b    (a0)+,d1    ; Char kopieren
  25.     cmp.b    #$0a,d1        ; Return erreicht ?
  26.     beq.s    found        ; Ja > Gefunden !
  27.     move.b    d1,(a1)+    ; Sonst Char in String kopieren
  28.     bra.s    search        ; Weiter nach Return suchen
  29. found:    move.b    #$0,(a1)+    ; Nullbyte ans Stringende
  30.     bsr.s    init        ; Dos.library oeffnen
  31. ; -----------------------------------------------------------------
  32. ; File oeffnen und Daten reinlesen
  33. ; -----------------------------------------------------------------
  34.     move.l    #$60000,d1    ; Zeiger auf Filenamen
  35.     move.l    #1005,d2    ; Modus : ALT
  36.     jsr    -30(a5)        ; DosCall OPEN
  37.     cmp.l    #0,d0        ; Error ?
  38.     beq.s    error        ; Ja, also nichts wie raus hier
  39.     move.l    d0,a3        ; Filehandle sichern
  40.     moveq    #10,d3        ; 10 Zeichen
  41.     move.l    #filemsg,d2    ; 'Loading.'-Message
  42.     jsr    -60(a5)        ; DosCall OUTPUT
  43.     jsr    -48(a5)        ; DosCall WRITE
  44.     move.l    a3,d1        ; Zeiger aufs File
  45.     move.l    #$60080,d2    ; Zeiger auf den String
  46.     move.l    #1024,d3    ; 1024 Zeichen reinlesen
  47.     jsr    -42(a5)        ; DosCall READ
  48.     move.l    a3,d1        ; Zeiger aufs File
  49.     jsr    -36(a5)        ; DosCall CLOSE
  50. ; -----------------------------------------------------------------
  51. ; Und jetzt schreiben wir das Ganze wieder in den Bootblock. Dazu
  52. ; oeffnen wir ( wie schon bei BBSave ) das Trackdiskdevice, schauen
  53. ; nach ob eine Disk vorhanden ist und speichern unsere Daten ab.
  54. ; -----------------------------------------------------------------
  55.     lea    diskio,a1    ; IO-Struktur
  56.     moveq    #0,d0        ; df0:
  57.     moveq    #0,d1        ; keine Flags
  58.     lea    trackdev,a0    ; Trackdisk-Device
  59.     jsr    -444(a6)    ; ExecCall OPENDEVICE
  60.     tst.l    d0        ; Error ?
  61.     bne.L    error        ; Ja, also nichts wie raus hier !
  62.     lea    diskio,a1    ; IO-Struktur
  63.     move.l    #readreply,14(A1); Zeiger auf unseren Task
  64.     move    #14,28(a1)    ; TDComm. CHangestate (Diskette eingelegt?)
  65.     move.l    4,a6        ; Execbase in a6
  66.     jsr    -456(a6)    ; ExecCall DOIO
  67.     lea    diskio,a1    ; IO-Struktur
  68.     move.l    #readreply,14(A1); Zeiger auf unseren Task
  69.     move    #3,28(a1)    ; TDCommand WRITE
  70.     move.l    #$60080,40(a1)    ; Zeiger auf unseren Buffer
  71.     move.l    #1024,36(a1)    ; 2 Sektoren einlesen
  72.     move.l    #0,44(a1)    ; von Sektor 0 Spur 0
  73.     move.l    4,a6        ; Execbase in a6
  74.     jsr    -456(a6)    ; ExecCall DOIO
  75. ; -----------------------------------------------------------------
  76. ; Alles wieder schliessen
  77. ; -----------------------------------------------------------------
  78.     lea    diskio,a1    ; IO-Struktur
  79.     move.l    #readreply,14(A1); Zeiger auf unseren Task
  80.     move    #9,28(a1)    ; TDCommand TD-MOTOR
  81.     move.l    #0,36(a1)    ; Motor ausschalten
  82.     jsr    -456(a6)    ; ExecCall DOIO
  83.     lea    readreply,a1    ; Task-Struktur
  84.     jsr    -360(a6)    ; ExecCall REMOVEPORT
  85.     lea    diskio,a1    ; IO-Struktur
  86.     jsr    -450(a6)    ; ExecCall CLOSEDEVICE
  87. close:    move.l     a5,a1        ; Dosbase zurueckholen
  88.     jsr     -414(a6)    ; Und Schliesen..
  89. error:    rts            ; Zurueck ins CLI
  90. ; -----------------------------------------------------------------
  91. ; Subroutine, die die Dos.library oeffnet und die Basisadresse sichert
  92. ; -----------------------------------------------------------------
  93. init:    move.l    4,a6        ; Execbase
  94.     lea    dosname,a1    ; Dos.library
  95.     jsr    -408(a6)    ; ExecCall OPENLIBRARY
  96.     move.l    d0,a5        ; dosbase retten
  97.     rts            ; Zurueck
  98. ; -----------------------------------------------------------------
  99. ; Subroutine, wenn keine Parameter eingegeben wurden
  100. ; -----------------------------------------------------------------
  101. nofile:    bsr.s    init        ; dos.lib oeffnen
  102.     moveq    #10,d3        ; 10 Zeichen
  103.     move.l    #nofilemsg,d2    ; 'Bad Args.'-Message
  104.     jsr    -60(a5)        ; DosCall OUTPUT
  105.     jsr    -48(a5)        ; DosCall WRITE
  106.     bra.s    close        ; Raus aus dem Programm
  107. ; -----------------------------------------------------------------
  108. ; Labels
  109. ; -----------------------------------------------------------------
  110. dosname: dc.b 'dos.library',0
  111. trackdev: dc.b 'trackdisk.device',0
  112. nofilemsg: dc.b "Bad Args",$a,0
  113. filemsg: dc.b "Loading.",$a,0
  114. even
  115. diskio: blk.l 20,0
  116. readreply: blk.l 8,0
  117.